package com.xmb.wechat.bean;

import java.io.Serializable;
import java.util.Date;

import io.objectbox.annotation.Entity;
import io.objectbox.annotation.Id;

/**
 * 微信首页，聊天列表，显示最新的一条聊天
 */
@Entity
public class WechatLastMsgBean implements Serializable, Comparable<WechatLastMsgBean> {

    @Id
    private long id;
    //是否是群聊
    private boolean isRoomChat;
    //聊天对象的ID，可能是个人或者群(看isRoomChat的值)
    private long talkerID;
    private long senderID;
    private String msgContent;
    private Date time;
    //未读数量
    private int unReadCount;

    @Override
    public String toString() {
        return "WechatLastMsgBean{" +
                "id=" + id +
                ", isRoomChat=" + isRoomChat +
                ", talkerID=" + talkerID +
                ", senderID=" + senderID +
                ", msgContent='" + msgContent + '\'' +
                ", time=" + time +
                ", unReadCount=" + unReadCount +
                '}';
    }

    public int getUnReadCount() {
        return unReadCount;
    }

    public void setUnReadCount(int unReadCount) {
        this.unReadCount = unReadCount;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public boolean isRoomChat() {
        return isRoomChat;
    }

    public void setRoomChat(boolean roomChat) {
        isRoomChat = roomChat;
    }

    public long getTalkerID() {
        return talkerID;
    }

    public void setTalkerID(long talkerID) {
        this.talkerID = talkerID;
    }

    public long getSenderID() {
        return senderID;
    }

    public void setSenderID(long senderID) {
        this.senderID = senderID;
    }

    public String getMsgContent() {
        return msgContent;
    }

    public void setMsgContent(String msgContent) {
        this.msgContent = msgContent;
    }

    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }

    @Override
    public int compareTo(WechatLastMsgBean o) {
        return (int) (o.getTime().getTime() - getTime().getTime());
    }
}
